-
Notifications
You must be signed in to change notification settings - Fork 463
fix: prevent IDOR vulnerability in environment update endpoint #6384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Docker builds report
|
api/environments/serializers.py
Outdated
| def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
| super().__init__(*args, **kwargs) # type: ignore[no-untyped-call] | ||
| # Prevent IDOR: project cannot be changed after creation | ||
| if self.instance is not None: | ||
| self.fields["project"].read_only = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A neater option here is probably just to separate the Create and Update serializers?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6384 +/- ##
=======================================
Coverage 98.02% 98.02%
=======================================
Files 1282 1282
Lines 45498 45514 +16
=======================================
+ Hits 44600 44617 +17
+ Misses 898 897 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
90b1762 to
cd0e004
Compare
Make the `project` field read-only during environment updates to prevent attackers from moving an environment to a different project they don't own. The vulnerability allowed an attacker with access to their own environment to modify the `project` field in the PUT request body, effectively moving their environment into a victim's project. Fix: Override __init__ in CreateUpdateEnvironmentSerializer to set project field as read-only when instance exists (update operation).
cd0e004 to
d29b554
Compare
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature!Changes
Make the
projectfield read-only during environment updates to prevent attackers from moving an environment to a different project they don't own.The vulnerability allowed an attacker with access to their own environment to modify the
projectfield in the PUT request body, effectively moving their environment into a victim's project.Fix: Override init in CreateUpdateEnvironmentSerializer to set project field as read-only when instance exists (update operation).
How did you test this code?
Adds unit test